<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CartoonController extends Controller
{
   /*
        后台首页
   */
        public function getIndex(Request $request)
        {	
            
            $tid = $request->input('tid');
            //获取分类数据
            $cates=DB::table('shop_types')->where('pid',2)->get();
            // dd($cates);
            //tid非空则按tid查找  否则全部查询
        	if(!empty($tid)){
               $goods = DB::table('shop_goods')->where('tid',$tid)->get(); 
           }else{
               $goods = DB::table('shop_goods')->get(); 
           }
        	
        
            //解析模板 根目录为resources下的views
            return view('Home.Cartoon.index',['cates'=>$cates,'goods'=>$goods]);
            // echo 'book首页';
        }
}
